package biolabs.util;

import java.util.Iterator;

class TransformingIterator<I, O> implements Iterator<O>{

	private final Iterator<? extends I> i;
	private final Transformation<I,O> tr;

	TransformingIterator(Iterator<? extends I> i, Transformation<I,O> tr){
		this.i = i;
		this.tr = tr;
	}

	@Override
	public boolean hasNext() {
		return i.hasNext();
	}

	@Override
	public O next() {
		return tr.apply(i.next());
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}

}